package singleton;

// 懒汉式
// 类锁保证线程安全
class LazySingleton {
    private static LazySingleton instance = null;

    private LazySingleton() {
    }

    // 静态方法锁，锁住整个方法，效率比较低
    public synchronized static LazySingleton getInstance() {
        if (instance == null) {
            instance = new LazySingleton();
        }
        return instance;
    }
}
